import java.util.*;
import java.util.stream.Collectors;

public class TestDemo {

    public static void main(String[] args) {
        List<Map> aList = new ArrayList<Map>();
        Map bMap = new HashMap<String,Integer>();
        bMap.put("id",1);
        Map cMap = new HashMap<String,Integer>();
        cMap.put("id",2);
        Map dMap = new HashMap<String,Integer>();
        dMap.put("id",3);
        Map eMap = new HashMap<String,Integer>();
        eMap.put("id",1);
        aList.add(bMap);
        aList.add(cMap);
        aList.add(dMap);
        aList.add(eMap);
        System.out.println(test(aList,"id"));
    }

    static List<Map>  test(List<Map> a, String key){
        List<Map> result = a.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<Map>(Comparator.comparing(b->(Integer)b.get(key)))), ArrayList::new));
        return result;
    }


}
